package library.web.servlet.page;

import library.persistence.dao.MessageDao;
import library.persistence.impl.MessageDaoImpl;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;

public class MessagePageServlet extends HttpServlet {

    public static final String MESSAGE_PAGE = "/WEB-INF/jsp/messagePage.jsp";

    private String username;
    private String time;
    private String comment;

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        HttpSession session = req.getSession();
        MessageDao messageDao = new MessageDaoImpl();
        session.setAttribute("messageList",messageDao.getAllMessage());
        req.getRequestDispatcher(MESSAGE_PAGE).forward(req,resp);
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        this.doGet(req,resp);
    }
}
